package com.evaluationsystem.system.controller;

import com.evaluationsystem.Utils.UserContextUtils;
import com.evaluationsystem.system.dao.SysMenuDao;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("index")
public class IndexController {

    @Autowired
    UserContextUtils userContextUtils;

    @Autowired
    SysMenuDao dao;

    @GetMapping("")
    @ApiOperation(value = "主页面跳转接口",notes="map为返回携带当前登录用户名称")
    public String getIndexHtml(Map<Object,Object>map){
        map.put("username",userContextUtils.getUser().getUsername());
        return "public/index/index";
    }

    @GetMapping("getMenus")
    @ResponseBody
    @ApiOperation(value = "获取菜单")
    public List<Map<String,Object>> getMenus(){
        return dao.getMenus();
    }

    @GetMapping("main")
    @ApiOperation(value = "首页跳转")//system/main/main2,public/index/main2
    public String getMainHtml(){
        return "system/mian/main2";
    }

}
